﻿<%@ Control Language="C#" AutoEventWireup="true" Codebehind="FolderGalery.ascx.cs"
    Inherits="NCS.Module.Multimedia.Web.Gallery.FolderGalery" %>

<asp:DataList ID="dtgPicList" runat="server" Width="100%" CssClass="albumlist" RepeatColumns="3">
    <ItemStyle VerticalAlign="top" HorizontalAlign="center" />
    <ItemTemplate>
                <asp:HyperLink ID="link_image" CssClass="im_gall album_item" runat="server">            
                    <img alt='<%# Eval("AlbumName") %>' boder="0" src='<%# Eval("AlbumAvatar") %>' width="160" />
                </asp:HyperLink>
                <div class="thongtin_album">
                    <asp:HyperLink ID="link_name" runat="server" CssClass="xemalbum">
                    </asp:HyperLink>
                </div>
    </ItemTemplate>
</asp:DataList>
<hr />
<%

    string url = NCS.Library.AppEnv.DEFAULT_PAGE + "?portalid=" + NCS.Library.AppEnv.PortalId() + "&tabid=" + Request["tabid"] + "&catid=" + Request["catid"] + "&page={0}&total={1}";
    int pageCount = (int)Math.Ceiling((double)this.total / this.pagesize);
    
    int beginpage = this.page - 3;
        beginpage = beginpage <= 0 ? 0 : beginpage;

    int endpage = beginpage + 6;
    endpage = endpage >= pageCount ? pageCount : endpage;

    beginpage = endpage == pageCount ? endpage - 6 : beginpage;

    beginpage = beginpage <= 0 ? 0 : beginpage;

%>

<ul class="media_pagging">
    <%= "<li class=\"text_right1\">Có tổng " + pageCount + " trang</li>"%>
    <% if (pageCount > 1)
        { 
           if (this.page > 0)
           {
               Response.Write("<li><a href=\"" + string.Format(url, this.page - 1, this.total) + "\">Trang trước </a></li>");
           }
           
            for (int i2 = beginpage; i2 < endpage; i2++)
            {
                if (i2 != this.page)
                    Response.Write("<li><a class=\"text_right1\" href=\"" + string.Format(url, i2, this.total) + "\">" + (i2 + 1) + "</a> </li>");
                else
                {
                    Response.Write("<li><a class=\"text_right1 selected2\" href=\"#\" >  " + (i2 + 1) + " </a> </li>");
                }
            }

            if (this.page < pageCount - 1)
            {
                Response.Write("<li><a href=\"" + string.Format(url, this.page + 1, this.total) + "\"> Trang sau</a></li>");
            }
        } 
    %>
</ul>